package org.luxor.commons.elasticsearch.metadata;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

/**
 * @author Mr.Yan  @date 2019/9/26$
 */
@ApiModel(description = "分页结果")
public class EsPageResult<T> implements Serializable {

    @ApiModelProperty(value = "scroll分页快照Id", example = "1")
    private String scrollId;

    @ApiModelProperty(value = "当前页数", example = "1")
    private int current = 1;

    @ApiModelProperty(value = "每页记录数", example = "10")
    private int size = 10;

    @ApiModelProperty(value = "总记录数", example = "120")
    private long total = 0;

    @ApiModelProperty(value = "总页数", example = "12")
    private long totalPage = 0;

    @ApiModelProperty(value = "数据结果", example = "[{},{}]")
    private List<T> records = Collections.emptyList();

    public EsPageResult() {
        super();
    }

    public EsPageResult(int current, int size, int total, int totalPage, List<T> records) {
        this.current = current;
        this.size = size;
        this.total = total;
        this.totalPage = totalPage;
        this.records = records;
    }

    public String getScrollId() {
        return scrollId;
    }

    public void setScrollId(String scrollId) {
        this.scrollId = scrollId;
    }

    public int getCurrent() {
        return current;
    }

    public void setCurrent(int current) {
        this.current = current;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public long getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(long totalPage) {
        this.totalPage = totalPage;
    }

    public List<T> getRecords() {
        return records;
    }

    public void setRecords(List<T> records) {
        this.records = records;
    }

    @Override
    public String toString() {
        return "EsPageResult{" +
                "scrollId='" + scrollId + '\'' +
                ", current=" + current +
                ", size=" + size +
                ", total=" + total +
                ", totalPage=" + totalPage +
                ", records=" + records +
                '}';
    }
}
